package com.ki.erp.controller;

import com.ki.erp.domain.SqlUser;
import jakarta.annotation.Resource;
import jakarta.persistence.EntityManager;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sql/user")
public class SqlUserController {
    private @Resource EntityManager entityManager;

    @GetMapping("/add/age/{id}")
    @Transactional
    void addAge(@PathVariable String id) {
        SqlUser sqlUser = entityManager.find(SqlUser.class, id);
        sqlUser.setAge(sqlUser.getAge() + 1);
    }

}
